package com.offcn.dycommon.response;

import com.offcn.dycommon.enums.ResponseCodeEnume;

public class AppResponse<T> {
    private Integer code;

    public AppResponse() {
    }

    public AppResponse(Integer code, String mes, T data) {
        this.code = code;
        this.mes = mes;
        this.data = data;
    }

    private String mes;
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMes() {
        return mes;
    }

    public void setMes(String mes) {
        this.mes = mes;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
    public static <T>AppResponse<T> ok(T data){
        AppResponse<T> res = new AppResponse<T>();
        res.setCode(ResponseCodeEnume.success.getCode());
        res.setMes(ResponseCodeEnume.success.getMes());
        res.setData(data);
        return res;
    }
    public static <T>AppResponse<T> fail(T data){
        AppResponse<T> res = new AppResponse<T>();
        res.setCode(ResponseCodeEnume.FAIL.getCode());
        res.setMes(ResponseCodeEnume.FAIL.getMes());
        res.setData(data);
        return res;
    }
}
